/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Interfaz;

import Controladores.ControladorCuota;
import Controladores.ControladorPago;
import GestorCuota.Cuota;
import GestorJugadores.Jugador;
import GestorJugadores.JugadorBD;
import GestorPago.Pago;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author Ordoño
 */
public class InterfazPagoCuota extends javax.swing.JPanel {

    private static InterfazPagoCuota Instancia = null;
    String [] coljugadores = {"Nombre","Apellidos","Telefono","Correo","Forma de pago"};
    String [] colcuotas = {"Año de Nacimiento","Cuota de inscripcion","Mensualidad","Total","Temporada"};
    String [] cadenaMeses = {"Enero", "Febrero","Marzo","Abril","Mayo","Junio",
                            "Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"};
    String [] colpagos = {"Mes"};
    ArrayList<String> temporadas = null;
    ArrayList<Jugador> jugadores = new ArrayList<Jugador>();
    int opcion = 0; //1->Listar Impagos, 2-> Listar Pagos// 3-> Listar Pagos por jugador
                    //4->Pagos, 5->Cuotas
    
    
    /**
     * Creates new form InterfazPagoCuota
     */
    public InterfazPagoCuota() {
        initComponents();
        iniciar();
    }
    
    public static InterfazPagoCuota getInstancia() {
        if (Instancia==null){
            Instancia = new InterfazPagoCuota();
        }
        return Instancia;
    }
    
    
    public void limpiar()
    {
    }

        
    public void iniciar(){
    
        jPanel_Listar.setVisible(false);
        jPanel_PC.setVisible(false);
        jLabelTemporada.setVisible(false);
        jLabelMes.setVisible(false);
        Sel_Temporada.setVisible(false);
        Sel_Mes.setVisible(false);
        Boton_Buscar.setVisible(false);
        Boton_Anotar_Pago.setVisible(false);
        if (Datos_Listar.isVisible() )
            Datos_Listar.setVisible(false);
        Datos_Pagos.setVisible(false);
    }
        
    public void cargarTemporadas(){
    
        temporadas = ControladorCuota.getInstancia().getTemporadas();
        
    }
    
    public void cargarListar(){
    
        iniciar();
        jPanel_Listar.setVisible(true);
        jLabelTemporada.setVisible(true);
        jLabelMes.setVisible(true);
        Sel_Temporada.setVisible(true);
        Sel_Mes.setVisible(true);
        Boton_Buscar.setVisible(true);       
        Boton_Buscar.setEnabled(true);
        Boton_Anotar_Pago.setEnabled(true);
        
        if (temporadas == null){
        
            cargarTemporadas();
            Sel_Temporada.removeAllItems();
            for( String aux : temporadas){
        
            Sel_Temporada.addItem(aux);
            }
        }
        

        
        if (temporadas == null){
        
            Sel_Temporada.addItem("No hay temporadas");
        }
    }
    
    
    public void cargarJugadores( JTable tabla) {
     
            Collections.addAll(jugadores, JugadorBD.getInstancia().getJugador("", ""));

    
        
        
        Object[][] m = new Object[jugadores.size()][coljugadores.length];
        tabla.setModel(new DefaultTableModel(m,coljugadores));
        
        
        
        for (int i=0; i < jugadores.size(); ++i){
        
            tabla.setValueAt(jugadores.get(i).getNombre(), i, 0);
            tabla.setValueAt(jugadores.get(i).getApellidos(), i, 1);
            tabla.setValueAt(jugadores.get(i).getTelefono(), i, 2);
            tabla.setValueAt(jugadores.get(i).getCorreo(), i, 3);
            if (jugadores.get(i).getFormaPago().compareTo('P') == 0) {
                tabla.setValueAt("Único", i, 4);
            }
            else {
                tabla.setValueAt("Mensual", i, 4);
            }
                    
        }
    }
    
    public void cargarPC(){
    
        //iniciar();
        jPanel_PC.setVisible(true);
        Anio.setText("");
        Cuota_M.setText("");
        Cuota_I.setText("");
        Cuota_T.setText("");
        Tempo.setText("");
        
    }
    
    public void AgregarDatosPC(){
        
        jPanel_PC.setVisible(true);
        Anio.setText(  jTable1.getValueAt(jTable1.getSelectedRow(), 0).toString() );
        Cuota_M.setText(  jTable1.getValueAt(jTable1.getSelectedRow(), 1).toString() );
        Cuota_I.setText(  jTable1.getValueAt(jTable1.getSelectedRow(), 2).toString() );
        Cuota_T.setText(  jTable1.getValueAt(jTable1.getSelectedRow(), 3).toString() );
        Tempo.setText(  jTable1.getValueAt(jTable1.getSelectedRow(), 4).toString() );
    }
    
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jPanel_General = new javax.swing.JPanel();
        textoExito = new javax.swing.JLabel();
        jPanel_Listar = new javax.swing.JPanel();
        Sel_Mes = new javax.swing.JComboBox();
        Sel_Temporada = new javax.swing.JComboBox();
        jLabelTemporada = new javax.swing.JLabel();
        jLabelMes = new javax.swing.JLabel();
        Datos_Listar = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        Datos_Pagos = new javax.swing.JScrollPane();
        jTable3 = new javax.swing.JTable();
        Boton_Anotar_Pago = new javax.swing.JButton();
        Boton_Buscar = new javax.swing.JButton();
        jLabelOpcion = new javax.swing.JLabel();
        jPanel_PC = new javax.swing.JPanel();
        Informacion = new javax.swing.JLabel();
        Boton_Anadir_Modificar = new javax.swing.JButton();
        Anio = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        Cuota_I = new javax.swing.JTextField();
        Cuota_M = new javax.swing.JTextField();
        Cuota_T = new javax.swing.JTextField();
        Tempo = new javax.swing.JTextField();
        Boton_Listar_Impagos = new javax.swing.JButton();
        Boton_Listar_Pagos = new javax.swing.JButton();
        Boton_Cuotas = new javax.swing.JButton();
        Boton_Pagos_Jug = new javax.swing.JButton();

        jPanel1.setPreferredSize(new java.awt.Dimension(750, 532));

        jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Recursos/FCBGranada2.PNG"))); // NOI18N
        jLabel2.setText("jLabel2");

        jLabel3.setFont(new java.awt.Font("Andalus", 1, 24)); // NOI18N
        jLabel3.setText("FUNDACION CLUB BALONCESTO GRANADA");

        textoExito.setVisible(false);

        Sel_Mes.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre" }));
        Sel_Mes.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Sel_MesActionPerformed(evt);
            }
        });

        jLabelTemporada.setText("         Temporada");

        jLabelMes.setText("             Mes");

        jTable1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3"
            }
        ));
        jTable1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jTable1MouseClicked(evt);
            }
        });
        Datos_Listar.setViewportView(jTable1);

        jTable3.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3"
            }
        ));
        Datos_Pagos.setViewportView(jTable3);

        Boton_Anotar_Pago.setText("Anotar Pago");
        Boton_Anotar_Pago.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Boton_Anotar_PagoActionPerformed(evt);
            }
        });

        Boton_Buscar.setText("Buscar");
        Boton_Buscar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Boton_BuscarActionPerformed(evt);
            }
        });

        jLabelOpcion.setText("jLabel1");

        javax.swing.GroupLayout jPanel_ListarLayout = new javax.swing.GroupLayout(jPanel_Listar);
        jPanel_Listar.setLayout(jPanel_ListarLayout);
        jPanel_ListarLayout.setHorizontalGroup(
            jPanel_ListarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel_ListarLayout.createSequentialGroup()
                .addGap(10, 10, 10)
                .addGroup(jPanel_ListarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel_ListarLayout.createSequentialGroup()
                        .addGroup(jPanel_ListarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabelTemporada, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(Sel_Temporada, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabelMes, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(Sel_Mes, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(6, 6, 6)
                        .addComponent(Datos_Listar, javax.swing.GroupLayout.PREFERRED_SIZE, 419, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel_ListarLayout.createSequentialGroup()
                        .addGroup(jPanel_ListarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(Boton_Buscar, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(Boton_Anotar_Pago))
                        .addGap(6, 6, 6)
                        .addComponent(Datos_Pagos, javax.swing.GroupLayout.PREFERRED_SIZE, 448, javax.swing.GroupLayout.PREFERRED_SIZE))))
            .addGroup(jPanel_ListarLayout.createSequentialGroup()
                .addGap(182, 182, 182)
                .addComponent(jLabelOpcion, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE))
        );
        jPanel_ListarLayout.setVerticalGroup(
            jPanel_ListarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel_ListarLayout.createSequentialGroup()
                .addComponent(jLabelOpcion)
                .addGap(2, 2, 2)
                .addGroup(jPanel_ListarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel_ListarLayout.createSequentialGroup()
                        .addComponent(jLabelTemporada)
                        .addGap(6, 6, 6)
                        .addComponent(Sel_Temporada, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(11, 11, 11)
                        .addComponent(jLabelMes)
                        .addGap(6, 6, 6)
                        .addComponent(Sel_Mes, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(Datos_Listar, javax.swing.GroupLayout.PREFERRED_SIZE, 121, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel_ListarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel_ListarLayout.createSequentialGroup()
                        .addComponent(Boton_Buscar, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(6, 6, 6)
                        .addComponent(Boton_Anotar_Pago, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(Datos_Pagos, javax.swing.GroupLayout.PREFERRED_SIZE, 88, javax.swing.GroupLayout.PREFERRED_SIZE)))
        );

        Informacion.setText("Cuotas");

        Boton_Anadir_Modificar.setText("Añadir");
        Boton_Anadir_Modificar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Boton_Anadir_ModificarActionPerformed(evt);
            }
        });

        jLabel1.setText("Año de nacimiento");

        jLabel4.setText("Cuota de inscripción");

        jLabel5.setText("Cuota Mensual");

        jLabel6.setText("Cuota Total");

        jLabel7.setText("Temporada");

        javax.swing.GroupLayout jPanel_PCLayout = new javax.swing.GroupLayout(jPanel_PC);
        jPanel_PC.setLayout(jPanel_PCLayout);
        jPanel_PCLayout.setHorizontalGroup(
            jPanel_PCLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel_PCLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel_PCLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel_PCLayout.createSequentialGroup()
                        .addComponent(jLabel6)
                        .addGap(44, 44, 44)
                        .addComponent(Cuota_T)
                        .addGap(212, 212, 212))
                    .addGroup(jPanel_PCLayout.createSequentialGroup()
                        .addGroup(jPanel_PCLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(Informacion, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(jPanel_PCLayout.createSequentialGroup()
                                .addGroup(jPanel_PCLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(jPanel_PCLayout.createSequentialGroup()
                                        .addComponent(jLabel5)
                                        .addGap(29, 29, 29)
                                        .addComponent(Cuota_M, javax.swing.GroupLayout.PREFERRED_SIZE, 122, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 71, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGroup(jPanel_PCLayout.createSequentialGroup()
                                        .addComponent(jLabel4)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(Cuota_I, javax.swing.GroupLayout.PREFERRED_SIZE, 122, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(jLabel1)))
                                .addGap(18, 18, 18)
                                .addGroup(jPanel_PCLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(Anio, javax.swing.GroupLayout.PREFERRED_SIZE, 106, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(Tempo, javax.swing.GroupLayout.PREFERRED_SIZE, 109, javax.swing.GroupLayout.PREFERRED_SIZE))))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(Boton_Anadir_Modificar, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(0, 0, Short.MAX_VALUE))))
        );
        jPanel_PCLayout.setVerticalGroup(
            jPanel_PCLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel_PCLayout.createSequentialGroup()
                .addGroup(jPanel_PCLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel_PCLayout.createSequentialGroup()
                        .addComponent(Informacion)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel_PCLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel1)
                            .addComponent(Anio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel4)
                            .addComponent(Cuota_I, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel_PCLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel5)
                            .addComponent(Cuota_M, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(Tempo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jPanel_PCLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(Boton_Anadir_Modificar, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel_PCLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(Cuota_T, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(29, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jPanel_GeneralLayout = new javax.swing.GroupLayout(jPanel_General);
        jPanel_General.setLayout(jPanel_GeneralLayout);
        jPanel_GeneralLayout.setHorizontalGroup(
            jPanel_GeneralLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel_GeneralLayout.createSequentialGroup()
                .addGap(10, 10, 10)
                .addComponent(jPanel_Listar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addGroup(jPanel_GeneralLayout.createSequentialGroup()
                .addGap(10, 10, 10)
                .addComponent(jPanel_PC, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addGroup(jPanel_GeneralLayout.createSequentialGroup()
                .addGap(439, 439, 439)
                .addComponent(textoExito, javax.swing.GroupLayout.PREFERRED_SIZE, 145, javax.swing.GroupLayout.PREFERRED_SIZE))
        );
        jPanel_GeneralLayout.setVerticalGroup(
            jPanel_GeneralLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel_GeneralLayout.createSequentialGroup()
                .addGap(11, 11, 11)
                .addComponent(jPanel_Listar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(11, 11, 11)
                .addComponent(jPanel_PC, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(92, 92, 92)
                .addComponent(textoExito, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        Boton_Listar_Impagos.setText("Listar Impagos");
        Boton_Listar_Impagos.setPreferredSize(new java.awt.Dimension(130, 23));
        Boton_Listar_Impagos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Boton_Listar_ImpagosActionPerformed(evt);
            }
        });

        Boton_Listar_Pagos.setText("Listar Pagos");
        Boton_Listar_Pagos.setMaximumSize(new java.awt.Dimension(115, 23));
        Boton_Listar_Pagos.setMinimumSize(new java.awt.Dimension(115, 23));
        Boton_Listar_Pagos.setPreferredSize(new java.awt.Dimension(130, 23));
        Boton_Listar_Pagos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Boton_Listar_PagosActionPerformed(evt);
            }
        });

        Boton_Cuotas.setText("Cuotas");
        Boton_Cuotas.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Boton_CuotasActionPerformed(evt);
            }
        });

        Boton_Pagos_Jug.setText("Pagos por jugador");
        Boton_Pagos_Jug.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Boton_Pagos_JugActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jLabel2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(Boton_Listar_Impagos, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(Boton_Listar_Pagos, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(Boton_Cuotas, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(Boton_Pagos_Jug, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addComponent(jPanel_General, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 540, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel3)
                    .addComponent(jLabel2))
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(44, 44, 44)
                        .addComponent(Boton_Listar_Impagos, javax.swing.GroupLayout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(13, 13, 13)
                        .addComponent(Boton_Listar_Pagos, javax.swing.GroupLayout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(Boton_Pagos_Jug, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(Boton_Cuotas, javax.swing.GroupLayout.PREFERRED_SIZE, 51, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jPanel_General, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 750, Short.MAX_VALUE)
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGap(0, 0, Short.MAX_VALUE)
                    .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(0, 0, Short.MAX_VALUE)))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 532, Short.MAX_VALUE)
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGap(0, 0, Short.MAX_VALUE)
                    .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(0, 0, Short.MAX_VALUE)))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void Boton_Listar_ImpagosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Boton_Listar_ImpagosActionPerformed
        jLabelOpcion.setText("Listar Impagos");
        cargarListar();
        opcion = 1;

        
    }//GEN-LAST:event_Boton_Listar_ImpagosActionPerformed

    private void Boton_Listar_PagosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Boton_Listar_PagosActionPerformed
        jLabelOpcion.setText("Listar Pagos");
        cargarListar();
        opcion = 2;
        
        
    }//GEN-LAST:event_Boton_Listar_PagosActionPerformed

    private void Sel_MesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Sel_MesActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_Sel_MesActionPerformed

    private void Boton_CuotasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Boton_CuotasActionPerformed
        // TODO add your handling code here:
        jLabelOpcion.setText("Cuotas ");
        Informacion.setText("Cuotas");
        opcion = 5;
        cargarListar();
        //cargarPC();
        //ControladorCuota.getInstancia().getCuota("");
    }//GEN-LAST:event_Boton_CuotasActionPerformed

    private void Boton_Pagos_JugActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Boton_Pagos_JugActionPerformed
        // TODO add your handling code here:
        jLabelOpcion.setText("Listar Pagos por Jugador");
        cargarListar();
        Sel_Mes.setVisible(false);
        jLabelMes.setVisible(false);
        Boton_Buscar.setEnabled(false);
        Boton_Anotar_Pago.setVisible(true);
        Boton_Anotar_Pago.setEnabled(false);
        opcion = 3;
        Datos_Listar.setVisible(true);
        cargarJugadores(jTable1);
    }//GEN-LAST:event_Boton_Pagos_JugActionPerformed

    private void jTable1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTable1MouseClicked
        // TODO add your handling code here:
        Boton_Buscar.setEnabled(true);
        //Boton_Anotar_Pago.setVisible(true);
        //Boton_Anotar_Pago.setEnabled(true);
        if (opcion == 3) {
            Boton_Anotar_Pago.setText("Anotar Pago");
            ControladorPago.getInstancia().jugadores = jugadores;
            ControladorPago.getInstancia().jugadorActivo = jTable1.getSelectedRow();
        }
        else if (opcion == 5){
            Boton_Anotar_Pago.setVisible(true);
            Boton_Anotar_Pago.setEnabled(true);
            Boton_Anotar_Pago.setText("Añadir Cuota");
            ControladorCuota.getInstancia().cuotaActiva = jTable1.getSelectedRow();
            cargarPC();
            AgregarDatosPC();
            Boton_Anadir_Modificar.setText("Modificar");
        }
    }//GEN-LAST:event_jTable1MouseClicked

    private void Boton_Anotar_PagoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Boton_Anotar_PagoActionPerformed
        // TODO add your handling code here:
        if (opcion == 3){
        ControladorPago.getInstancia().AnotarPago((String)Sel_Temporada.getSelectedItem(),
                                                            (String)Sel_Mes.getSelectedItem());
        }
        else if (opcion == 5){
            cargarPC();
            Boton_Anadir_Modificar.setText("Añadir");
        }
    }//GEN-LAST:event_Boton_Anotar_PagoActionPerformed

    private void Boton_Anadir_ModificarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Boton_Anadir_ModificarActionPerformed
        // TODO add your handling code here:
        String [] datos = {Anio.getText(),Cuota_I.getText(),Cuota_M.getText(),Cuota_T.getText(),Tempo.getText()};

        if (Boton_Anadir_Modificar.getText().equals("Añadir")){
            ControladorCuota.getInstancia().addCuota(datos);
        }
        else if (Boton_Anadir_Modificar.getText().equals("Modificar")){      
            ControladorCuota.getInstancia().updateCuota(datos);
        }
        
    }//GEN-LAST:event_Boton_Anadir_ModificarActionPerformed

    private void Boton_BuscarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Boton_BuscarActionPerformed
        // TODO add your handling code here:
        cargarListar();
        //Datos_Listar.setVisible(true);

        if (opcion == 1){

            ControladorPago.getInstancia().GenerarListadoImpago((String) Sel_Temporada.getSelectedItem(),
                                                                (String) Sel_Mes.getSelectedItem());
        }
        else if (opcion == 2){

            ControladorPago.getInstancia().GenerarListadoPago((String) Sel_Temporada.getSelectedItem(),
                                                                (String) Sel_Mes.getSelectedItem());
            
        }
        else if (opcion == 3){
            ControladorPago.getInstancia().GenerarListadoPagoJugador((String) Sel_Temporada.getSelectedItem());
            Boton_Anotar_Pago.setVisible(true);
            Boton_Anotar_Pago.setEnabled(true);
            
        }
        else if (opcion == 5){
            Boton_Anotar_Pago.setText("Añadir Cuota");
            Boton_Anotar_Pago.setVisible(true);
            ControladorCuota.getInstancia().getCuota(-1, (String)Sel_Temporada.getSelectedItem());
        }
        
    }//GEN-LAST:event_Boton_BuscarActionPerformed

    
    public void mostrarTablaPagos(ArrayList<Jugador> jugadores){
    
        Object[][] m = new Object[jugadores.size()][coljugadores.length];
        jTable1.setModel(new DefaultTableModel(m,coljugadores));
        
        
        
        for (int i=0; i < jugadores.size(); ++i){
        
            jTable1.setValueAt(jugadores.get(i).getNombre(), i, 0);
            jTable1.setValueAt(jugadores.get(i).getApellidos(), i, 1);
            jTable1.setValueAt(jugadores.get(i).getTelefono(), i, 2);
            jTable1.setValueAt(jugadores.get(i).getCorreo(), i, 3);
            if (jugadores.get(i).getFormaPago().compareTo('P') == 0) {
                jTable1.setValueAt("Único", i, 4);
            }
            else {
                jTable1.setValueAt("Mensual", i, 4);
            }
                    
        }
        Datos_Listar.setVisible(true);
    }
    public void mostrarTablaImpagos(ArrayList<Jugador> jugadores){
    
        
        Object[][] m = new Object[jugadores.size()][coljugadores.length];
        jTable1.setModel(new DefaultTableModel(m,coljugadores));
        
        
        
        for (int i=0; i < jugadores.size(); ++i){
        
            jTable1.setValueAt(jugadores.get(i).getNombre(), i, 0);
            jTable1.setValueAt(jugadores.get(i).getApellidos(), i, 1);
            jTable1.setValueAt(jugadores.get(i).getTelefono(), i, 2);
            jTable1.setValueAt(jugadores.get(i).getCorreo(), i, 3);
            if (jugadores.get(i).getFormaPago().compareTo('P') == 0) {
                jTable1.setValueAt("Único", i, 4);
            }
            else {
                jTable1.setValueAt("Mensual", i, 4);
            }
                    
        }
        Datos_Listar.setVisible(true);
        
    }
    public void mostrarTablaPagosJugador(ArrayList<Pago> pagos){
    
        Object[][] m = new Object[pagos.size()][colpagos.length];
        jTable3.setModel(new DefaultTableModel(m,colpagos));
        
        
        
        for (int i=0; i < pagos.size(); ++i){
        
            jTable3.setValueAt(pagos.get(i).getMes(), i, 0);

                    
        }
        Datos_Listar.setVisible(true);
        Datos_Pagos.setVisible(true);
    }
    
    public void mostrarTablaCuotas(ArrayList<Cuota> cuotas){
    
        Object[][] m = new Object[cuotas.size()][colcuotas.length];
        jTable1.setModel(new DefaultTableModel(m,colcuotas));
        
        
        
        for (int i=0; i < cuotas.size(); ++i){
        
            jTable1.setValueAt(cuotas.get(i).getAnioNacimiento(), i, 0);
            jTable1.setValueAt(cuotas.get(i).getCuotadeInscripcion(), i, 1);
            jTable1.setValueAt(cuotas.get(i).getCuotaMensual(), i, 2);
            jTable1.setValueAt(cuotas.get(i).getCuotaTotal(), i, 3);
            jTable1.setValueAt(cuotas.get(i).getTemporada(), i, 4);

                    
        }
        Datos_Listar.setVisible(true);
    }
    
    public void mostrarMensaje(String mensaje, String titulo, int tipo) {
        //JOptionPane.showConfirmDialog(null, mensaje, titulo, tipo);
        JOptionPane.showMessageDialog(null, mensaje, titulo, tipo);
    }
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextField Anio;
    private javax.swing.JButton Boton_Anadir_Modificar;
    private javax.swing.JButton Boton_Anotar_Pago;
    private javax.swing.JButton Boton_Buscar;
    private javax.swing.JButton Boton_Cuotas;
    private javax.swing.JButton Boton_Listar_Impagos;
    private javax.swing.JButton Boton_Listar_Pagos;
    private javax.swing.JButton Boton_Pagos_Jug;
    private javax.swing.JTextField Cuota_I;
    private javax.swing.JTextField Cuota_M;
    private javax.swing.JTextField Cuota_T;
    private javax.swing.JScrollPane Datos_Listar;
    private javax.swing.JScrollPane Datos_Pagos;
    private javax.swing.JLabel Informacion;
    private javax.swing.JComboBox Sel_Mes;
    private javax.swing.JComboBox Sel_Temporada;
    private javax.swing.JTextField Tempo;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabelMes;
    private javax.swing.JLabel jLabelOpcion;
    private javax.swing.JLabel jLabelTemporada;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel_General;
    private javax.swing.JPanel jPanel_Listar;
    private javax.swing.JPanel jPanel_PC;
    private javax.swing.JTable jTable1;
    private javax.swing.JTable jTable3;
    private javax.swing.JLabel textoExito;
    // End of variables declaration//GEN-END:variables
}
